package com.smartscreen.schedulemanage.service.impl;


import com.smartscreen.schedulemanage.dto.CreateExamScheduleRequest;
import com.smartscreen.schedulemanage.entity.ExamSchedule;
import com.smartscreen.schedulemanage.mapper.ExamScheduleMapper;
import com.smartscreen.schedulemanage.service.ExamScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class ExamScheduleServiceImpl implements ExamScheduleService {
    
    @Autowired
    private ExamScheduleMapper examScheduleMapper;
    
    @Override
    public String createExamSchedule(CreateExamScheduleRequest request) {
        String examId = "ex_" + UUID.randomUUID().toString().substring(0, 8);
        
        ExamSchedule examSchedule = new ExamSchedule();
        examSchedule.setExamId(examId);
        examSchedule.setName(request.getName());
        examSchedule.setTermId(request.getTermId());
        
        examScheduleMapper.insert(examSchedule);
        
        // 这里还需要插入年级关联和考试详情数据
        // 为了简化，这里只返回examId
        
        return examId;
    }
    
    @Override
    public List<ExamSchedule> getExamSchedules(String termId, String gradeId) {
        return examScheduleMapper.getExamSchedules(termId, gradeId);
    }
}